AT-NFC  2.1 (win)
AT-NFC kernel set
Data Structures | Typedefs | Functions
hal_crypt.h File Reference
#include <emv_platform_set_align.h>
#include <emv_platform_restore_align.h>

Go to the source code of this file.

Data Structures

struct  tag_HAL_CRYPT_PK
 Get PK info structure. More...
 
struct  tag_HAL_CRYPT_CERT_INFO
 Check certificate revocation cert info structure. More...
 

Macros

#define KER_HASH_ALG_TC_HASH   0
 
#define KER_HASH_ALG_SHA1   1
 
#define KER_HASH_ALG_SHA256   2
 
#define KER_HASH_ALG_SHA512   3
 
#define KER_HASH_ALG_SHA3_256   4
 
#define KER_HASH_ALG_SHA3_512   5
 
#define KER_HASH_ALG_SM3   6
 
#define KER_CRYPT_ALG_DES   0
 
#define KER_CRYPT_ALG_AES   10
 
#define KER_CA_PK_SCHEME_NA   0
 
#define KER_CA_PK_SCHEME_RSA   1
 
#define KER_CA_PK_SCHEME_ECC   2
 
#define KER_REC_ALG_RSA_EMV   1
 
#define KER_HASH_SHA1_LEN   20
 
#define KER_HASH_SHA256_LEN   32
 
#define KER_HASH_SHA512_LEN   64
 
#define KER_HASH_SHA3_256_LEN   32
 
#define KER_HASH_SHA3_512_LEN   64
 
#define KER_HASH_SM3_LEN   32
 
#define KER_PK_MODULUS_LEN   248
 
#define KER_PK_EXP_LEN   3
 
#define KER_PK_HASH_LEN   20
 
#define KER_ECC_PK_P256_LEN   32
 
#define KER_ECC_PK_P521_LEN   66
 
#define KER_ECC_ASI_EC_SDSA_SHA256_P256   1
 
#define KER_ECC_ASI_EC_SDSA_SHA512_P521   2
 
#define KER_ECC_ASI_EC_SDSA_SHA3_256_P256   3
 
#define KER_ECC_ASI_EC_SDSA_SHA3_512_P521   4
 
#define KER_ECC_ASI_SM2_DSA_SM3_SM2_P256   5
 
#define KER_ECC_ASI_ODE_DH_EtM_AES_P256   20
 
#define KER_ECC_ASI_ODE_DH_EtM_AES_P521   21
 
#define KER_ECC_ASI_ODE_DH_EtM_SM4_SM2_P256   22
 

Typedefs

typedef struct tag_HAL_CRYPT_PK HAL_CRYPT_PK
 Get PK info structure.
 
typedef struct tag_HAL_CRYPT_CERT_INFO HAL_CRYPT_CERT_INFO
 Check certificate revocation cert info structure.
 

Functions

KER_INT16U hal_crypt_get_hash_len (KER_CTX_PARAM KER_BYTE btAlg)
 Returns HASH length by Hash ALG according to EMV Book 2, Appendix B3. More...
 
KER_BOOL hal_crypt_calc_hash (KER_CTX_PARAM KER_BYTE btAlg, KER_VOID *pExtra, const KER_BYTE *pbtDataBuffer, KER_INT16U usDataBufferLen, KER_BYTE *pbtHash, KER_INT16U *pusHashLen, KER_INT16U usHashSize)
 Calculates hash for data buffer provided. More...
 
KER_BOOL hal_crypt_calc_hash_init (KER_CTX_PARAM KER_BYTE btAlg, KER_VOID *pExtra, KER_VOID **ppHashHandle)
 Initiates hash calculation. More...
 
KER_BOOL hal_crypt_calc_hash_update (KER_CTX_PARAM KER_VOID *pHashHandle, KER_BYTE btAlg, const KER_BYTE *pbtDataBuffer, KER_INT16U usDataBufferLen)
 Passes data for hash calculation (can be executed several times) More...
 
KER_BOOL hal_crypt_calc_hash_complete (KER_CTX_PARAM KER_VOID *pHashHandle, KER_BYTE btAlg, KER_BYTE *pbtHash, KER_INT16U *pusHashLen, KER_INT16U usHashSize)
 Calculates hash on prev. provided data. More...
 
KER_BOOL hal_crypt_unpredict_num_calc (KER_CTX_PARAM KER_INT16U usUnpredNumLen, KER_BYTE *pbtUnpredNum)
 Calculates unpredictable number. More...
 
KER_BOOL hal_crypt_unpredict_num_set_ac (KER_CTX_PARAM const KER_BYTE *pbtAc, KER_INT16U usAcLen)
 Updates unpredictable (random) number calculator with last AC (9F26) value (only if it was obtained from card) More...
 
KER_BOOL hal_crypt_encrypt (KER_CTX_PARAM KER_BYTE btAlg, const KER_BYTE *pbtKey, KER_INT16U usKeyLen, const KER_BYTE *pbtIV, KER_INT16U usIVLen, const KER_BYTE *pbtData, KER_INT16U usDataLen, KER_BYTE *pbtResult, KER_INT16U *pusResultLen, KER_INT16U usMaxLen)
 Performs encryption. More...
 
KER_BOOL hal_crypt_decrypt (KER_CTX_PARAM KER_BYTE btAlg, const KER_BYTE *pbtKey, KER_INT16U usKeyLen, const KER_BYTE *pbtIV, KER_INT16U usIVLen, const KER_BYTE *pbtEncryptedData, KER_INT16U usEncryptedDataLen, KER_BYTE *pbtResult, KER_INT16U *pusResultLen, KER_INT16U usMaxLen)
 Performs decryption. More...
 
KER_BOOL hal_crypt_get_ca_pk (KER_CTX_PARAM KER_BYTE btKernelID, const KER_BYTE *pbtRID, KER_BYTE btRIDLen, KER_BYTE btKeyIndex, HAL_CRYPT_PK *pCA_PK)
 Get CA PK by index from repositoty. More...
 
KER_BOOL hal_crypt_msg_recovery (KER_CTX_PARAM const KER_BYTE *pbtPK, KER_INT16U usPKLen, const KER_BYTE *pbtExp, KER_INT16U usExpLen, KER_BYTE btAlg, const KER_BYTE *pbtMsg, KER_INT16U usMsgLen, KER_BYTE *pbtResult, KER_INT16U *pusResultLen, KER_INT16U usMaxLen)
 Message recovery according to EMV Book 2, Appendix A2.1. More...
 
KER_BOOL hal_crypt_check_cert_revocation (KER_CTX_PARAM KER_BYTE btKernelID, const KER_BYTE *pbtRID, KER_BYTE btRIDLen, KER_BYTE btKeyIndex, const HAL_CRYPT_CERT_INFO *pCert)
 Checks certificate against certificatye revocation list. More...
 
KER_BOOL hal_crypt_check_ecc_cert_revocation (KER_CTX_PARAM KER_BYTE btKernelID, const KER_BYTE *pbtRID, KER_BYTE btRIDLen, KER_BYTE btKeyIndex, const HAL_CRYPT_CERT_INFO *pCert)
 Checks ECC certificate against certificatye revocation list. More...
 
KER_INT16U hal_ecc_get_sign_len (KER_CTX_PARAM KER_BYTE btASI)
 Returns ECC message signature length by ASI according to EMV Book 2, Appendix B2.4.1. More...
 
KER_INT16U hal_ecc_get_pk_len (KER_CTX_PARAM KER_BYTE btASI)
 Returns ECC PK length by ASI according to EMV Book 2, Appendix B2.4.1. More...
 
KER_BOOL hal_ecc_msg_sign_check (KER_CTX_PARAM KER_BYTE btASI, const KER_BYTE *pbtPK, KER_INT16U usPKLen, const KER_BYTE *pbtMsg, KER_INT16U usMsgLen, const KER_BYTE *pbtSignature, KER_INT16U usSignatureLen)
 ECC message signature check according to EMV Book 2, Appendix A2.2.3. More...
 
KER_BOOL hal_ecc_pk_check (KER_CTX_PARAM KER_BYTE btASI, const KER_BYTE *pbtPK, KER_INT16U usPKLen)
 ECC pk check Recover the y-coordinate EMV Book 2, Appendix B2.2.1e. More...
 
KER_BOOL hal_ecc_msg_sign_check_init (KER_CTX_PARAM KER_BYTE btASI, const KER_BYTE *pbtPK, KER_INT16U usPKLen, const KER_BYTE *pbtSignature, KER_INT16U usSignatureLen, KER_VOID **ppCheckHandle)
 ECC message signature check according to EMV Book 2, Appendix A2.2.3 (Initiates check) More...
 
KER_BOOL hal_ecc_msg_sign_check_update (KER_CTX_PARAM KER_VOID *pCheckHandle, const KER_BYTE *pbtMsg, KER_INT16U usMsgLen)
 ECC message signature check according to EMV Book 2, Appendix A2.2.3 (Update wuth MSG data) More...
 
KER_BOOL hal_ecc_msg_sign_check_complete (KER_CTX_PARAM KER_VOID *pCheckHandle, KER_BYTE btASI, const KER_BYTE *pbtPK, KER_INT16U usPKLen, const KER_BYTE *pbtSignature, KER_INT16U usSignatureLen)
 ECC message signature check according to EMV Book 2, Appendix A2.2.3 (Completes check) More...
 

Detailed Description

HAL crypto functions interface definition